<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>基本资料</title>
    <link rel="stylesheet" href="../../lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
    <link rel="stylesheet" href="css/personalInformation.css">
    <script src="../../lib/jquery-3.4.1/jquery-3.4.1.min.js"></script>
    <script src="../../lib/layui-v2.6.3/layui.js"></script>
</head>
<body>
    <div class="layuimini-container out-box">
        <div class="layuimini-main">
    
            <div class="layui-form layuimini-form">
                <div class="layui-form-item">
                    <label class="layui-form-label">员工id：</label>
                    <div class="layui-input-block">
                        <input type="text" name="t-id" id="t-id" value="" class="layui-input" readonly>
                    </div>
                </div>
    
                <div class="layui-form-item">
                    <label class="layui-form-label">员工姓名：</label>
                    <div class="layui-input-block">
                        <input type="text" name="t-name" id="t-name" readonly value="" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">学历：</label>
                    <div class="layui-input-block">
                        <input type="text" name="educational" id="t-educational" readonly value="" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">所属部门：</label>
                    <div class="layui-input-block">
                        <input type="text" name="department" id="t-department" readonly value="" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">职位：</label>
                    <div class="layui-input-block">
                        <input type="text" name="position" id="t-position" readonly value="" class="layui-input">
                    </div>
                </div>
    
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn layui-btn-normal" onclick="go()">点此完善信息</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
<script>
    $(function(){
        //呈现实时数据
        setInterval(init,50);
    })
    //数据呈现
    function init(){
        //获取本地存储的数据
        let tuser=JSON.parse(localStorage.getItem("key"));
        //循环数据
        one:
        for(let i=0;i<tuser.length;i++){
            //拿登录员工的id
            let tId=JSON.parse(localStorage.getItem("tId"));
            two:
            for(let j=0;j<tId.length;j++){
                let loginId=tId[0].id;
                // console.log(loginId);  //拿到当前员工的id
                if(loginId==tuser[i].id){
                    console.log(tuser[i].educational);
                    $("input[name='t-id']").val(tuser[i].id);
                    $("input[name='t-name']").val(tuser[i].userName);
                    $("input[name='educational']").val(tuser[i].educational);
                    $("input[name='department']").val(tuser[i].department);
                    $("input[name='position']").val(tuser[i].position);
                    break one;
                }
            }
        }
    }
    //跳转至编辑页面
    function go(){
        $(location).attr("href","changeInformation.html");
    }
</script>
</body>
</html>